<?php


namespace app\common;

use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;

//定义一个实现过滤器的类，使用IReadFilter
class ExcelReadFilter implements IReadFilter
{
    private $col_start;
    private $col_end;

    public function __construct($col_start, $col_end)
    {
        $this->col_start = $col_start;
        $this->col_end = $col_end;
    }

    public function readCell($column, $row, $worksheetName = '')
    {
        //只读A~D列的数据
        if (in_array($column, range($this->col_start, $this->col_end))) {
            return true;
        }
        return false;
    }
}